#include "AbstractState.h"
#include <QAction>
#include "Context.h"

//--------------------------------------------------------------------------------
AbstractState::AbstractState(Context* context, const QString name, const QString image):
        QObject()
{
    _context = context;
    _stateName = name;
    _imageName = image;
}
//--------------------------------------------------------------------------------
AbstractState::~AbstractState()
{
}
//--------------------------------------------------------------------------------
const QString AbstractState::getName()
{
    return _stateName;
}
//--------------------------------------------------------------------------------
const QString AbstractState::getImageName()
{
    return _imageName;
}
//--------------------------------------------------------------------------------
void AbstractState::setAction(QAction* action)
{
    _action = action;

    connect(_action, SIGNAL(triggered()), this, SLOT(activate()));
    _action->setVisible(true);
}
//--------------------------------------------------------------------------------
void AbstractState::activate()
{
    qDebug(QString("AbstractState:: %1 state is activated").arg(_stateName).toLatin1());

    _action->setChecked(true);

    emit activated();
}
//--------------------------------------------------------------------------------
void AbstractState::deactivate()
{
    qDebug(QString("AbstractState:: %1 state is deactivated").arg(_stateName).toLatin1());
    _action->setChecked(false);
}
//--------------------------------------------------------------------------------
